# HTML <table> Tag

## Example

A simple HTML table, containing two columns and two rows:

<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
Try it Yourself »

More "Try it Yourself" examples below.

## Definition and Usage

The <table> tag defines an HTML table.

An HTML table consists of the <table> element and one or more <tr>, <th>, and <td> elements.

The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell.

A more complex HTML table may also include <caption>, <col>, <colgroup>, <thead>, <tfoot>, and <tbody> elements.

## Browser Support

Element |  |  |  |  |
--- | --- | --- | --- | --- | ---
<table> | Yes | Yes | Yes | Yes | Yes

## Differences Between HTML 4.01 and HTML5

The "align", "bgcolor", "border", "cellpadding", "cellspacing", "frame", "rules", "summary", and "width" attributes are not supported in HTML5.

| There has been some disagreement in W3C, about removing the "border" attribute in HTML5. Finally, it has been removed from the specification. Use CSS instead!

## Attributes

Attribute | Value | Description
--- | --- | ---
align | left center right | Not supported in HTML5. Specifies the alignment of a table according to surrounding text
bgcolor | rgb(x,x,x) #xxxxxx colorname | Not supported in HTML5. Specifies the background color for a table
border | 1 0 | Not supported in HTML5. Specifies whether the table cells should have borders or not
cellpadding | pixels | Not supported in HTML5. Specifies the space between the cell wall and the cell content
cellspacing | pixels | Not supported in HTML5. Specifies the space between cells

frame

void
above
below
hsides
lhs
rhs
vsides
box
border

Not supported in HTML5.
Specifies which parts of the outside borders that should be visible

rules | none groups rows cols all | Not supported in HTML5. Specifies which parts of the inside borders that should be visible
sortable | sortable | Specifies that the table should be sortable
summary | text | Not supported in HTML5. Specifies a summary of the content of a table
width | pixels % | Not supported in HTML5. Specifies the width of a table

## Global Attributes

The <table> tag also supports the Global Attributes in HTML.

## Event Attributes

The <table> tag also supports the Event Attributes in HTML.

## Try it Yourself - Examples

Table headers
How to create table headers.

Table with a caption
An HTML table with a caption.

Tags inside a table
How to display elements inside other elements.

Cells that span more than one row/column
How to define table cells that span more than one row or one column.

## Related Pages

HTML tutorial: HTML Tables

HTML DOM reference: Table Object

## Default CSS Settings

Most browsers will display the <table> element with the following default values:

## Example

table {
display: table;
border-collapse: separate;
border-spacing: 2px;
border-color: gray;
}
Try it Yourself »

### WEB HOSTING

UK Reseller Hosting

### WEB BUILDING

FREE Website BUILDER Free HTML5 Templates

### W3SCHOOLS EXAMS

HTML, CSS, JavaScript, PHP, jQuery, XML, and ASP Certifications

### SHARE THIS PAGE

### Color Picker

### HTML/CSS

HTML Tutorial HTML5 Tutorial CSS Tutorial CSS3 Tutorial Bootstrap Tutorial

### JavaScript

JavaScript Tutorial jQuery Tutorial jQuery Mobile Tutorial AngularJS Tutorial AJAX Tutorial JSON Tutorial

### Graphics

Canvas Tutorial SVG Tutorial Google Maps Tutorial

### Server Side

SQL Tutorial PHP Tutorial ASP Tutorial ASP.NET Tutorial VBScript Tutorial AppML Tutorial

### Web

Web Building Web Statistics Web Certification

### XML

XML Tutorial DTD Tutorial Schema Tutorial XML DOM Tutorial XPath Tutorial XSLT Tutorial XQuery Tutorial XSL-FO Tutorial RSS Tutorial WSDL Tutorial

### HTML/CSS

HTML Tag Reference HTML Event Reference HTML Color Reference CSS 1,2,3 Reference Bootstrap Reference

### JavaScript

JavaScript Reference HTML DOM Reference jQuery Reference jQuery Mobile Reference Google Maps Reference

### Server Side

PHP Reference SQL Reference ASP Reference VBScript Reference Razor Reference ASP.NET Reference

### XML

XML DOM Reference XSLT Reference XSL-FO Reference XPath Reference XQuery Reference Schema Reference RSS Reference SVG Reference

### HTML Charsets

HTML Character Sets HTML ASCII HTML ANSI HTML Windows-1252 HTML ISO-8859-1 HTML Symbols HTML UTF-8

### HTML/CSS

HTML Examples CSS Examples

### Browser Scripting

JavaScript Examples HTML DOM Examples jQuery Examples jQuery Mobile Examples AngularJS Examples AJAX Examples

### Server Scripting

PHP Examples ASP Examples VBScript Examples Razor Examples .NET Examples

### XML Languages

XML Examples DTD Examples XML DOM Examples XSL Examples XSLT Examples XPath Examples XQuery Examples Schema Examples RSS Examples SVG Examples